Skip to content

chore(detectors): Prevent Query Injection detector from running on SQL queries #96690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2025

Conversation

roggenkemper
Copy link
Member

fixes an edge case where some oddly formed SQL requests were getting picked up by the query injection detector (not the sql injection one)

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 29, 2025
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #96690       +/-   ##
===========================================
+ Coverage   66.12%   80.66%   +14.53%     
===========================================
  Files        8465     8481       +16     
  Lines      372806   373635      +829     
  Branches    24205    24205               
===========================================
+ Hits       246521   301387    +54866     
+ Misses     125912    71875    -54037     
  Partials      373      373               

@roggenkemper roggenkemper marked this pull request as ready for review July 29, 2025 23:22
@roggenkemper roggenkemper requested review from a team as code owners July 29, 2025 23:22

sql_keywords = ("SELECT", "UPDATE", "INSERT")
if any(description.upper().startswith(keyword) for keyword in sql_keywords):
return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SQL Exclusion Flaws: DELETE Missing, Whitespace Ignored

The sql_keywords tuple, intended to exclude common SQL queries from query injection detection, is missing "DELETE", a fundamental DML operation. This omission means "DELETE" queries are not excluded, leading to inconsistent behavior. Additionally, the keyword check does not account for leading whitespace in the span description, allowing queries like " SELECT * FROM users" to bypass the exclusion filter and still be processed by the detector, defeating its purpose of preventing false positives for common SQL operations.

Locations (1)
Fix in Cursor Fix in Web

Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth adding a test?

@roggenkemper roggenkemper merged commit 99acd8c into master Jul 31, 2025
64 checks passed
@roggenkemper roggenkemper deleted the roggenkemper/rmsqlfromquery branch July 31, 2025 16:22
andrewshie-sentry pushed a commit that referenced this pull request Aug 4, 2025
…L queries (#96690)

fixes an edge case where some oddly formed SQL requests were getting
picked up by the query injection detector (not the sql injection one)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants